import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEAction } from '../dataentity/action/ipsdeaction';
import { IPSWFDEActionProcess } from './ipswfdeaction-process';
import { PSWFProcessImpl } from './pswfprocess-impl';

export class PSWFDEActionProcessImpl extends PSWFProcessImpl implements IPSWFDEActionProcess {
  get dEActionName(): string {
    return this.M.dEActionName;
  }

  protected psdeaction: IPSDEAction | null = null;

  getPSDEAction(): IPSDEAction | null {
    if (this.psdeaction != null) return this.psdeaction;
    const value = this.M.getPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.psdeaction;
  }

  get psDEAction(): IPSDEAction | null {
    return this.getPSDEAction();
  }

  getPSDEActionMust(): IPSDEAction {
    const value = this.getPSDEAction();
    if (value == null) {
      throw new Error('未指定实体行为');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSWFDEActionProcessImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWFDEActionProcess') return true;
    return super.instanceof(cls);
  }
}
